﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Klasifikasi.aspx.vb" Inherits="bisaska.Klasifikasi" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="server">
<script language="javascript">
    function ClientValidate(source, arguments) {
        var resp = 0;

        $.ajax({
            url: "Klasifikasi.aspx/IsExist",
            data: '{ "KodeKlasifikasi": "' + arguments.Value + '"}',
            type: "POST",
            async: false,
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            success: function (result) {
                resp = result.d;
            },
            error: function (e) {
                alert(e);
            }
        });

        if (resp == "0") {
            arguments.IsValid = true;
        } else {
            arguments.IsValid = false;
        }
    }
</script> 
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<form id="FormUnit" runat="server">

<asp:ScriptManager runat="server" ID="MainScriptManager" OnAsyncPostBackError="MainScriptManager_AsyncPostBackError" EnablePartialRendering="true">
  <Scripts>
   <asp:ScriptReference Path="~/Scripts/script-manager.js" />
  </Scripts>
</asp:ScriptManager> 

<asp:UpdatePanel runat="server" ID="MainUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>

<div class="title">
    <span>.::</span>
    <span><b>Master Klasifikasi</b></span>
    <em>::.</em>
	<em><%= DateTime.Now.ToString("dd MMMM yyyy")%></em>
	<div style="clear:both;"></div>
</div>

<asp:GridView 
    ID="KlasifikasiGridView" 
    runat="server" 
    AllowPaging="True" 
    AllowSorting="True" 
    AutoGenerateColumns="False" 
    DataKeyNames="id_klasifikasi"
    DataSourceID="KlasifikasiSqlDataSource" 
    PageSize="8" 
    CellPadding="4" 
    GridLines="None" 
    AlternatingRowStyle-CssClass="odd"
    CssClass="table-data"
    EmptyDataText="Data kosong !!"
    EmptyDataRowStyle-CssClass="empty-data">
    <AlternatingRowStyle CssClass="odd" />
<Columns>
    <asp:BoundField DataField="id_klasifikasi" HeaderText="ID" SortExpression="id_klasifikasi" />
    <asp:BoundField DataField="kode_klasifikasi" HeaderText="KODE KLAS" SortExpression="kode_klasifikasi" />
    <asp:BoundField DataField="deskripsi" HeaderText="DESKRIPSI" SortExpression="deskripsi" />
    <asp:BoundField DataField="jenis_dok" HeaderText="JENIS DOK" SortExpression="jenis_dok" />
    <asp:BoundField DataField="nilai_guna" HeaderText="NILAI GUNA" SortExpression="nilai_guna" />
    <asp:BoundField DataField="nomor_se" HeaderText="NOMOR SE" SortExpression="nomor_se" />
    <asp:BoundField DataField="tgl_se" HeaderText="TANGGAL SE" SortExpression="tgl_se" DataFormatString="{0:dd-MMM-yyyy}"/>
    <asp:BoundField DataField="is_active" HeaderText="STATUS" 
        SortExpression="status" ItemStyle-Width="70px">
    <ItemStyle Width="70px" />
    </asp:BoundField>
    <asp:BoundField DataField="tgl_update" HeaderText="TGL UPDATE" 
        SortExpression="tgl_update" DataFormatString="{0:dd-MMM-yyyy}" 
        ItemStyle-Width="90px">
    <ItemStyle Width="90px" />
    </asp:BoundField>
    <asp:ButtonField CommandName="EditCommand" Text="Edit" ItemStyle-Width="25px" >
    <ItemStyle Width="25px" />
    </asp:ButtonField>
    <asp:TemplateField ItemStyle-Width="25px">
      <ItemTemplate>
        <asp:LinkButton ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete"/>
        <ajaxToolkit:ModalPopupExtender 
            ID="DeleteModalPopupExtender" 
            BackgroundCssClass="overlay"
            runat="server" 
            TargetControlID="DeleteButton" 
            PopupControlID="DeletePanel" 
            OkControlID="ButtonDeleteOkay" 
            CancelControlID="ButtonDeleteCancel">
        </ajaxToolkit:ModalPopupExtender>
        <ajaxToolkit:ConfirmButtonExtender 
            ID="DeleteConfirmButtonExtender" 
            runat="server" 
            Enabled="True"
            TargetControlID="DeleteButton" 
            DisplayModalPopupID="DeleteModalPopupExtender">
        </ajaxToolkit:ConfirmButtonExtender>
      </ItemTemplate>
        <ItemStyle Width="25px" />
    </asp:TemplateField>
    <asp:ButtonField CommandName="CopyCommand" Text="Copy" ItemStyle-Width="25px">
    <ItemStyle Width="25px" />
    </asp:ButtonField>
  </Columns>
    <EmptyDataRowStyle CssClass="empty-data" />
</asp:GridView>

<a href="#" style="display:none;visibility:hidden;" onclick="return false" ID="DummyLink" runat="server">dummy</a>
<ajaxToolkit:ModalPopupExtender 
    ID="InfoModalPopupExtender" 
    BackgroundCssClass="overlay"
    runat="server" 
    TargetControlID="DummyLink" 
    PopupControlID="InfoPanel" 
    OkControlID="ButtonInfo"/>

<asp:Panel runat="server" ID="InfoPanel"  Style="display: none; width:200px;" CssClass="dialog-box">
  <h3>Info</h3> 
  <p>Operasi berhasil</p>
  <div class="dialog-buttons">
     <asp:Button ID="ButtonInfo" runat="server" Text="OK" CssClass="button" Width="70px"/>
  </div>
</asp:Panel>

<asp:Panel runat="server" ID="DeletePanel" Style="display: none; width:200px;" CssClass="dialog-box">
  <h3>Hapus data</h3> 
  <p>Hapus Data?</p>
  <div class="dialog-buttons">
    <input style="width:70px;" id="ButtonDeleteOkay" value="OK" type="button" class="button"/>
    <input style="width:70px;" id="ButtonDeleteCancel" value="Cancel" type="button" class="button"/>
  </div>
</asp:Panel>

<div class="paging">
  <em><asp:Button ID="AddButton" runat="server" Text="Add New" CausesValidation="False" CssClass="button" Enabled="false"/></em><div style="clear:both;"></div>
</div> 

<table runat="server" id="KlasifikasiTabelForm" cellpadding="0" cellspacing="2" border="0" class="table-form">
<tr>
  <th style="width:140px;">ID Klasifikasi</th>
  <td><asp:TextBox ID="IdKlasifikasi" runat="server" Columns="5" Enabled="false"></asp:TextBox></td>
</tr>
<tr>
  <th>Kode Klasifikasi</th>
  <td>
    <asp:TextBox ID="KodeKlasifikasi" runat="server" MaxLength="8" Columns="8"></asp:TextBox>
    <asp:RequiredFieldValidator 
        ID="KodeKlasifikasiRequiredFieldValidator" 
        runat="server" 
        ControlToValidate="KodeKlasifikasi" 
        Display="Dynamic"
        ErrorMessage="Data harus diisi !!"/>
    <asp:CustomValidator 
        id="KodeKlasifikasiValidator"
        ControlToValidate="KodeKlasifikasi"
        ClientValidationFunction="ClientValidate"
        Display="Dynamic"
        ErrorMessage="Data sudah ada !!"
        runat="server" />
  </td>
</tr>
<tr>
  <th>Nilai Guna</span></th>
  <td>
    <asp:TextBox ID="NilaiGuna" runat="server" Columns="50" MaxLength="50"></asp:TextBox>
    <asp:RequiredFieldValidator 
        ID="NilaiGunaRequiredFieldValidator" 
        runat="server" 
        ControlToValidate="NilaiGuna" 
        Display="Dynamic"
        ErrorMessage="Data harus diisi !!"/>
  </td>
</tr>
<tr>
  <th valign="top">Deskripsi</th>
  <td>
    <asp:TextBox ID="Deskripsi" runat="server" Rows="1" Columns="80" TextMode="MultiLine"  MaxLength="150" />
    <asp:RequiredFieldValidator 
        ID="DescripsiRequiredFieldValidator" 
        runat="server" 
        ControlToValidate="Deskripsi" 
        Display="Dynamic"
        ErrorMessage="Data harus diisi !!"/>
    </td>
</tr>
<tr>
  <th>Nomor SE</th>
  <td>
    <asp:TextBox ID="NomorSE" runat="server" Columns="25" MaxLength="25"></asp:TextBox>
    <asp:RequiredFieldValidator 
        ID="NomorSERequiredFieldValidator" 
        runat="server" 
        ControlToValidate="NomorSE" 
        Display="Dynamic"
        ErrorMessage="Data harus diisi !!"/>
  </td>
</tr>
<tr>
  <th>Tanggal SE</th>
  <td>
    <asp:TextBox ID="TanggalSE" runat="server" MaxLength="10" ReadOnly="true"></asp:TextBox>
    <asp:CalendarExtender 
        ID="TanggalSECalendarExtender" 
        runat="server" 
        Enabled="True" 
        TargetControlID="TanggalSE" 
        Format="dd/MM/yyyy"/>
    <asp:RequiredFieldValidator 
        ID="TanggalSERequiredFieldValidator" 
        runat="server" 
        ControlToValidate="TanggalSE" 
        Display="Dynamic"
        ErrorMessage="Data harus diisi !!"/>
    </td>
</tr>
<tr>
  <th>Jenis Dokumen</th>
  <td>
    <asp:DropDownList 
        ID="JenisDokumen" 
        runat="server" 
        DataSourceID="JenisDokumenSqlDataSource" 
        DataTextField="jenis_dok" 
        DataValueField="id_jenis_dok"/>
  </td>
</tr>
<tr>
  <th>Status</th>
  <td>
    <asp:DropDownList ID="Status" runat="server">
      <asp:ListItem Value="0">Aktif</asp:ListItem>
      <asp:ListItem Value="1">Pasif</asp:ListItem>
    </asp:DropDownList>
  </td>
</tr>
<tr>
  <td></td>
  <td>
    <asp:Button Width="70px" ID="SaveButton" runat="server" Text="Save" CssClass="button"></asp:Button>
    <asp:Button Width="70px" ID="CancelButton" runat="server" Text="Cancel" CssClass="button" CausesValidation="False"></asp:Button>
  </td>
  </tr>
</table>

<asp:SqlDataSource 
    ID="KlasifikasiSqlDataSource" 
    runat="server" 
    ConnectionString="<%$ ConnectionStrings:bisaska %>" 
    SelectCommand="select a.id_klasifikasi, kode_klasifikasi, a.deskripsi, b.jenis_dok, nilai_guna,nomor_se, a.tgl_se, is_active = case a.is_active when 0 then 'Aktif' else 'Pasif' end, a.tgl_update from T_MST_KLASIFIKASI a join T_MST_JENIS_DOK b on a.id_jenis_dok = b.id_jenis_dok "
    
        DeleteCommand="DELETE FROM [T_MST_KLASIFIKASI] WHERE [id_klasifikasi] = @id_klasifikasi">
    <DeleteParameters>
      <asp:Parameter Name="id_klasifikasi" Type="Int64" />
    </DeleteParameters>
</asp:SqlDataSource>

<asp:SqlDataSource 
    ID="JenisDokumenSqlDataSource" 
    runat="server" 
    ConnectionString="<%$ ConnectionStrings:bisaska %>" 
    SelectCommand="SELECT id_jenis_dok, jenis_dok FROM T_MST_JENIS_DOK">
</asp:SqlDataSource>   

</ContentTemplate>
</asp:UpdatePanel>                          
</form>
</asp:Content>
